<template>
	<view>
		<view class="box-bg">
			<uni-nav-bar statusBar="true" shadow="true" backgroundColor="#00133f">
				<view class="input-view">
					<uni-icons class="input-uni-icon" type="search" size="18" color="#999" @click="sear" />
					<input confirm-type="search" class="nav-bar-input" type="text" placeholder="输入搜索关键词" v-model="data"
						@keydown.enter="sear" />
				</view>



			</uni-nav-bar>




		</view>
		<view class="banner_box" v-if="flag==0">
			<swiper class="swiper" indicator-dots="true"  autoplay="true" circular="true" interval="3000" >
			<swiper-item>
				<image src="../../static/swiper/s1.png" class="banner"></image>
			</swiper-item>
			<swiper-item>
				<image src="../../static/swiper/s2.png" class="banner" ></image>
			</swiper-item>
			<swiper-item>
				<image src="../../static/swiper/s3.png" class="banner" ></image>
			</swiper-item>
			<swiper-item>
				<image src="../../static/swiper/s4.png" class="banner" ></image>
			</swiper-item>
				
		</swiper>
		</view>
		<view v-if="flag==1">
			<view style="position: absolute;top:300rpx;" v-if="student.name!='false'">
				<t-table border="0" border-color="#fffff">
					<t-tr font-size="18" color="#ffffff" align="center"
						style="width: 700rpx;font-weight: 700;">
						<t-th align="center">{{student.name}}基础信息:</t-th>
						<t-th align="center"></t-th>
					</t-tr>
					<t-tr font-size="15" color="#ffffff" align="center" >
						<t-td align="left">学号</t-td>
						<t-td align="left">{{student.num}}</t-td>
					</t-tr>
					<t-tr font-size="15" color="#ffffff" align="center" >
						<t-td align="left">联系电话</t-td>
						<t-td align="left">{{student.tel}}</t-td>
					</t-tr>
					<t-tr font-size="15" color="#ffffff" align="center">
						<t-td align="left">核算检查结果</t-td>
						<t-td align="left">{{student.jian}}</t-td>
					</t-tr>
					<t-tr font-size="17" color="#ffffff" align="center" >
						<t-th align="left">密接人员：</t-th>

					</t-tr>
					<t-tr font-size="12" color="#ffffff" align="center" v-for="(item,index) in student.mj" >
						<t-td align="center" ><text @click="clickSear(item.name)">{{item.name}}</text></t-td>
						<t-td align="center" ><text @click="clickSear(item.name)">{{item.location}}</text></t-td>

					</t-tr>
					<t-tr font-size="17" color="#ffffff" align="center" >
						<t-th align="left">到过的地址：</t-th>

					</t-tr>
					<t-tr >
						<map style="width:90%;height: 500rpx;margin-left:50rpx;margin-top: 100rpx;" subkey="IEUBZ-QYBLW-QMRRC-RYRJ4-UXEKV-BXB3E"
				id="map1"
				:longitude="student.location[0].longitude"
				:latitude="student.location[0].latitude"
			     enable-traffic=true
				 enable-overlooking=true
				:markers="student.location" 
				layer-style="1"></map>
					</t-tr>
					<t-tr font-size="17" color="#ffffff" align="center" >
						<t-th>预案推荐：</t-th>
					</t-tr>
					<t-tr v-if="student.jian=='阴性'" v-for="(item,index) in advice1" font-size="15" color="#ffffff" align="left" >
						<t-td>{{item}}</t-td>
					</t-tr>
					<t-tr v-if="student.jian=='阳性'" v-for="(item,index) in advice1" font-size="15" color="#ffffff" align="center" >
						<t-td>{{item}}</t-td>
					</t-tr>
				</t-table>
			</view>
			<view v-if="student.name=='false'"><text
					style="position: absolute;top:300rpx;color:#ffffff;font-size:80rpx;font-weight: 1000;">未找到该人物</text></view>

			
		</view>
	</view>


</template>

<script>
	import tTable from '@/components/t-table/t-table.vue';
	import tTh from '@/components/t-table/t-th.vue';
	import tTr from '@/components/t-table/t-tr.vue';
	import tTd from '@/components/t-table/t-td.vue';

	export default {
		mounted(){
			var mapCon=uni.createMapContext('map1')
			 console.log(mapCon)
			
		},
		components: {
			tTable,
			tTd,
			tTh,
			tTr
		},
		computed: {
			student() {
				
				return this.stu
			}
		},
		data() {
			return {
				advice1:[
					"未发现阳性人员",
					"建议1：每24小时抽查10%的人员",
					"建议2：对每个快递酒精处理后才可获取",
					"建议3：定时对教学楼和宿舍楼杀菌处理",
					"建议4：人员外出时要佩戴口罩",
					"建议5：发布通行证，严防无关人士入校",
					"建议6：校内人员每日及时上报体温"
				],
				advice2:[
					"发现阳性人员",
					"建议1：封闭综合楼，数学楼，第三餐厅，第三餐厅",
					"建议2：每24小时抽查全部的人员",
					"建议3：停用快递",
					"建议4：定时对教学楼和宿舍楼杀菌处理",
					"建议5：所有密接人员隔离观察",
					"建议6：校内人员每日及时上报体温"
				],
				locationJW:[
					{id:1,name: '第一餐厅',latitude: 35.58032, longitude: 116.98660},
					{id:2,name: '数学楼',latitude: 35.58058, longitude: 116.98540},
					{id:3,name: '物理楼',latitude: 35.58000, longitude: 116.98665},
					{id:4,name: '综合楼',latitude:35.58030,  longitude: 116.98550},
					{id:5,name: '第二餐厅',latitude: 35.58035, longitude: 116.98600},
					{id:6,name: '第三餐厅',	latitude: 35.58000, longitude: 116.98600}
				
				],
				stu :{
						name: "",
						num: "",
						tel: "",
						jian: "",
						location: [],
						mj:[]
						},
				data: "",
				flag: 0,

			}
		},
		props: ["search"],
		methods: {
			sear() {
				// if (!this.data.trim()) return alert('输入不能为空')
				// var a=0;
				// this.studentList.forEach((stu) => {
				// 	if (stu.name == this.data) {
				// 		a=1
				// 		this.student = stu
				// 		console.log("s")
						
				// 	}
				
				

				// })
				// if(a==0){
				// 	this.student={name:"false"}
				// 	console.log("s")}
				this.stu ={
						name: "",
						num: "",
						tel: "",
						jian: "",
						location: [],
						mj:[]
						}
				uni.request({
					header: {
						'Content-Type': 'application/json'
					},
					url: "https://knowledge.darryllin.cn/editkg",
					method: "POST",
					data: {
						"conterm": this.data,
						"dbname":"KG_590017",
						"userno":"2017416616"
						
					},
					success: (res) => {
						
						if(res.data.data.graph.nodes.length==0)
						{
							this.stu.name="false"
						}
						else{this.stu.name=res.data.data.graph.nodes[0].label}
						
						this.stu.num=res.data.data.graph.nodes[res.data.data.graph.nodes.length-3].label
						this.stu.tel=res.data.data.graph.nodes[res.data.data.graph.nodes.length-2].label
						this.stu.jian=res.data.data.graph.nodes[res.data.data.graph.nodes.length-1].label
						res.data.data.graph.nodes.forEach((loca)=>{
							this.locationJW.forEach((locaJw)=>{
								if(locaJw.name==loca.label){
									uni.request({
										header: {
											'Content-Type': 'application/json'
										},
										url: "https://knowledge.darryllin.cn/editkg",
										method: "POST",
										data: {
											"conterm": locaJw.name,
											"dbname":"KG_590017",
											"userno":"2017416616"
											
										},
										success: (res) => {
											console.log(res)
										for(var i=2;i<res.data.data.graph.nodes.length-2;i++){
											var flag=1;
											this.stu.mj.forEach((m)=>{
												if(res.data.data.graph.nodes[i].label==this.data){
													
													console.log("data:"+this.data)
													flag=0;
												}
												if(res.data.data.graph.nodes[i].label==m.name){
													console.log("data2:"+this.data)
													flag=0;
												}
												
											})
											if(flag==1){
												var mjBase={name:"",location:""}
												mjBase.name=res.data.data.graph.nodes[i].label
												mjBase.location=res.data.data.graph.nodes[0].label
												this.stu.mj.push(mjBase)
											}
											
										}
										
										}
									})
									var locationBase={
									id: 0,
									latitude: 35.58035, //纬度
									longitude: 116.98600, //经度
				
									rotate: 0, // 旋转度数
									width: 15, //宽
									height: 20, //高
									alpha: 1, //透明度
									callout: { //自定义标记点上方的气泡窗口 点击有效  
										content: "", //文本

										color: '#ffffff', //文字颜色
										fontSize: 10, //文本大小
										borderRadius: 17, //边框圆角
										borderWidth: '6',
										bgColor: '#0000ff', //背景颜色
				
									},
								}
								
									locationBase.id=locaJw.id
									locationBase.callout.content=locaJw.name
									locationBase.latitude=locaJw.latitude
									locationBase.longitude=locaJw.longitude
									this.stu.location.push(locationBase)
									
								}
							})
						})
						
					}
				})
				this.flag = 1
				
				
				//清空输入
				// this.data = ''
			},
			clickSear(item){
				this.data=item
				console.log(item)
				this.sear()
			}
		},

	}
</script>

<style lang="scss" scoped>
	$nav-height: 55rpx;

	.box-bg {
		background-color: #00001d;

		height: 120rpx;
	}



	.input-view {
		/* #ifndef APP-PLUS-NVUE */
		display: flex;
		/* #endif */
		flex-direction: row;
		flex: 1;
		background-color: #f8f8f8;
		height: $nav-height;
		border-radius: 15px;
		padding: 0 5px;
		flex-wrap: nowrap;
		line-height: $nav-height;
	}



	.nav-bar-input {
		height: $nav-height;
		//width: 700rpx;
		line-height: $nav-height;
		/* #ifdef APP-PLUS-NVUE */
		//width: 370rpx;
		/* #endif */
		padding: 0 5px;
		font-size: 11px;

		background-color: #f8f8f8;
	}
	.banner_box{
		display: flex;
		margin-top: 200rpx;
		width: 100%;
		padding: 20rpx;
		justify-content: center; //垂直居中
		align-items: center;	 //水平居中
		border-radius: 5px;		 //圆角
	
		.swiper{
			width: 90%;
			height: 400rpx;
			.banner{
				width: 90%;
				height: 400rpx;
			}
		}
	}
</style>
